08. Check for Understanding: Lists

Check for Understanding

Data types and data structures are tricky but important concepts to master! Let's pause and make sure you understand the distinction between them.

Which of the following statements about data types and data structures are true? Select all that apply.

SOLUTION:
  • Data structures are containers that can include different data types.
  • A list is an example of a data structure.
  • All data structures are data types.

Which of the following are properties of lists? Select all that apply.

SOLUTION:
  • Mutable
  • Ordered

The next two quizzes will test your understanding of indexing and slicing lists. I encourage you to try answering these questions without testing them in code first. However, if you would like to experiment with code after your first try, there is a code editor at the bottom of this page for you to do so.

QUIZ QUESTION::

Choose the correct syntax to index each of the following elements from a list, arr.

ANSWER CHOICES:



Element

Indexing Syntax

First element of the list

Fourth element of a list

Last element of the list

Second to last element of the list

SOLUTION:

Element

Indexing Syntax

First element of the list

Fourth element of a list

Last element of the list

Second to last element of the list

QUIZ QUESTION::

Choose the correct syntax to slice each of the following elements from the list: arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g']

ANSWER CHOICES:



Elements

Slicing Syntax

['c', 'd', 'e', 'f']

['a', 'b', 'c']

['e', 'f', 'g']

SOLUTION:

Elements

Slicing Syntax

['a', 'b', 'c']

['c', 'd', 'e', 'f']

['e', 'f', 'g']

Start Quiz:

arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
print(arr[0])